﻿using System;

class Program
{
    static void Main()
    {
        // 定义要检查的数值类型
        Type[] types = {
            typeof(sbyte), typeof(byte),
            typeof(short), typeof(ushort),
            typeof(int), typeof(uint),
            typeof(long), typeof(ulong),
            typeof(float), typeof(double),
            typeof(decimal)
        };

        // 输出表头
        Console.WriteLine("{0,-10} {1,10} {2,30} {3,30}", "Type", "Size (Bytes)", "Min Value", "Max Value");

        // 遍历每种类型并输出信息
        foreach (var type in types)
        {
            object minValue = GetMinValue(type);
            object maxValue = GetMaxValue(type);
            int size = GetSize(type);

            Console.WriteLine("{0,-10} {1,10} {2,30} {3,30}", type.Name, size, minValue, maxValue);
        }

        // 等待用户按下回车键后再退出
        Console.WriteLine("\nPress Enter to exit...");
        Console.ReadLine();
    }

    // 获取类型的最小值
    static object GetMinValue(Type type)
    {
        if (type == typeof(sbyte)) return sbyte.MinValue;
        if (type == typeof(byte)) return byte.MinValue;
        if (type == typeof(short)) return short.MinValue;
        if (type == typeof(ushort)) return ushort.MinValue;
        if (type == typeof(int)) return int.MinValue;
        if (type == typeof(uint)) return uint.MinValue;
        if (type == typeof(long)) return long.MinValue;
        if (type == typeof(ulong)) return ulong.MinValue;
        if (type == typeof(float)) return float.MinValue;
        if (type == typeof(double)) return double.MinValue;
        if (type == typeof(decimal)) return decimal.MinValue;
        throw new ArgumentException("Unsupported type");
    }

    // 获取类型的最大值
    static object GetMaxValue(Type type)
    {
        if (type == typeof(sbyte)) return sbyte.MaxValue;
        if (type == typeof(byte)) return byte.MaxValue;
        if (type == typeof(short)) return short.MaxValue;
        if (type == typeof(ushort)) return ushort.MaxValue;
        if (type == typeof(int)) return int.MaxValue;
        if (type == typeof(uint)) return uint.MaxValue;
        if (type == typeof(long)) return long.MaxValue;
        if (type == typeof(ulong)) return ulong.MaxValue;
        if (type == typeof(float)) return float.MaxValue;
        if (type == typeof(double)) return double.MaxValue;
        if (type == typeof(decimal)) return decimal.MaxValue;
        throw new ArgumentException("Unsupported type");
    }

    // 获取类型的内存字节数
    static int GetSize(Type type)
    {
        if (type == typeof(sbyte)) return sizeof(sbyte);
        if (type == typeof(byte)) return sizeof(byte);
        if (type == typeof(short)) return sizeof(short);
        if (type == typeof(ushort)) return sizeof(ushort);
        if (type == typeof(int)) return sizeof(int);
        if (type == typeof(uint)) return sizeof(uint);
        if (type == typeof(long)) return sizeof(long);
        if (type == typeof(ulong)) return sizeof(ulong);
        if (type == typeof(float)) return sizeof(float);
        if (type == typeof(double)) return sizeof(double);
        if (type == typeof(decimal)) return sizeof(decimal);
        throw new ArgumentException("Unsupported type");
    }
}
